package com.lz.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * GroupBy.. map根据value过滤，筛选出符合提哦哦件的
 *
 * @author Lizhong
 * @date 2019/6/4
 */
public class GroupBy {
    private int a;
    private static int b;

    public static void main(String[] args) {

        List<Person> list = new ArrayList<>();
        list.add(new Person("a", 90));
        list.add(new Person("a", 80));
        list.add(new Person("b", 100));

        // 根据
        Map<String, List<Person>> collect = list.parallelStream().collect(Collectors.groupingBy(Person::getName, Collectors.toList()));
        Map<String, List<Person>> collect1 = collect.entrySet().parallelStream().filter(val -> val.getValue().size() > 1).collect(Collectors.toMap(val -> val.getKey(), val -> val.getValue()));

        System.out.println();
    }

    static class Person {
        public String name;
        public int scoce;

        public Person(String name, int scoce) {
            this.name = name;
            this.scoce = scoce;
        }

        public void method01() {
            System.out.println(b);
        }

        public static void method02() {
            System.out.println(b);
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getScoce() {
            return scoce;
        }

        public void setScoce(int scoce) {
            this.scoce = scoce;
        }
    }

    /**
     * 内部类，不允许you静态方法，可以访问成员和静态成员
     *
     * 静态内部类，可以又静态方法，只能访问静态字段
     */
    private class M {
        public void method01() {
            System.out.println(a);
            System.out.println(b);
        }
        /* public static void method02() {
            System.out.println(a);
            System.out.println(b);
        }*/

    }
}
